
<div style="margin-top: 100px" id="welcome">
    <h2 style="text-align: center"><?php echo $this->titulo; ?></h2>    
</div>

<?php if(!empty($this->turmasVencidas)) { ?>
<div style="margin-top: 50px" id="welcome">    
    <h4 style="text-align: center">Treinamentos Completando 1 Ano</h4>
</div>
<div  style="width: 1024px!important;display: block!important;margin-left: auto;margin-right: auto">
    <table style="margin: 0 auto!important" class="table table-bordered table-striped table-hover">
        <tr>
            <th>Treinamento</th>
            <th>Carga Horária</th>
            <th>Data de início</th>
            <th>Data de término</th>
            <th>Instrutor</th>
        </tr>
    
        <?php foreach ($this->turmasVencidas as $k => $turmas): ?>
            <tr style="cursor: pointer" class="<?php echo ($k % 2 == 0) ? 'alt' : '' ?> turma" id_turma="<?=$turmas['id_turma']?>">
                <td><?php echo $turmas['tx_nome_treinamento'] ?></td>
                <td><?php echo $turmas['nr_carga_horaria'] ?></td>
                <td><?php echo $this->String($turmas['dt_inicio_treinamento'])->reverseDate(); ?></td>
                <td><?php echo $this->String($turmas['dt_termino_treinamento'])->reverseDate(); ?></td>
                <td><?php echo $turmas['tx_nome_instrutor']; ?></td>
            </tr>
            <tr style="display: none" class="cliente_<?=$turmas['id_turma']?> cliente">
                <td colspan="5"style="text-align: center;" ><b>Clientes</b></td>
            </tr>
            <?php 
                $clientes = $turmas['clientes'];
            ?>
            <?php foreach ($clientes as $k => $cliente): ?>
                <tr style="display: none" class="cliente_<?=$turmas['id_turma']?> cliente">                
                    <td colspan="2" style="text-align: left"><?php echo $cliente['tx_cliente'] ?></td>
                    <td colspan="3" style="text-align: left">
                        <a href="mailto:<?php echo $cliente['tx_email'] ?>" target="_blank"><?php echo $cliente['tx_email'] ?></a>                        
                    </td>                
                </tr>
            <?php endforeach; ?>
        <?php endforeach; ?>
    </table>
</div>
<?php } ?>

<script>
    $(document).ready(function(){                
        $('.turma').click(function() {
            if($('.cliente_'+$(this).attr('id_turma')).is(':visible')) {
                $('.cliente_'+$(this).attr('id_turma')).hide();            
            } else {
                $('.cliente_'+$(this).attr('id_turma')).show();            
            }                        
        });               
    });
</script>
